﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using Jungle.Code.BLL;
using Jungle.Code.Utils;
using System.Collections.Generic;
using Jungle.Code.DAL;
using System.Data.SqlClient;

    public partial class more : UserControl
	{
        protected override void Render(HtmlTextWriter writer)
        {
            writer.AddAttribute(HtmlTextWriterAttribute.Width, "95%");
            writer.AddAttribute(HtmlTextWriterAttribute.Bgcolor, "#FFFFFF");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderWidth, "15");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderStyle, "solid");
            writer.AddStyleAttribute(HtmlTextWriterStyle.BorderColor, "#FFFFFF");
            writer.RenderBeginTag(HtmlTextWriterTag.Table);

            using (SqlConnection connect = new SqlConnection(DBHelper.ConnectionString))
            {
                SqlCommand command = new SqlCommand("mdUsers_GetById", connect);
                SqlParameter param_id_user = command.Parameters.Add("@id_user", SqlDbType.Int);
                SqlDataReader reader = null;
                param_id_user.Value = Convert.ToInt32(Request["id_user"]);
                command.CommandType = CommandType.StoredProcedure;

                command.Connection.Open();
                    reader = command.ExecuteReader();
                    while (reader.Read())
                    {
                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "40px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        writer.AddAttribute(HtmlTextWriterAttribute.Colspan, "2");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);

                        writer.AddAttribute(HtmlTextWriterAttribute.Src, "../Modules/UserManager/img/fUser.jpg");
                        writer.RenderBeginTag(HtmlTextWriterTag.Img);
                        writer.RenderEndTag();
                        writer.Write("<br/><br/>");
                            
                        writer.Write("<strong>Информация о пользователе:&nbsp;" + reader.GetValue(1).ToString() + "</strong>");
                        writer.Write("<br/><br/>");
                        writer.RenderEndTag();
                        writer.RenderEndTag();

                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "20px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        writer.AddAttribute(HtmlTextWriterAttribute.Width, "150px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.Write("<strong>Ф.И.О:</strong>");
                        writer.RenderEndTag();
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.Write(reader.GetValue(3).ToString());
                        writer.RenderEndTag();
                        writer.RenderEndTag();

                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "20px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        writer.AddAttribute(HtmlTextWriterAttribute.Width, "150px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.Write("<strong>E-mail:</strong>");
                        writer.RenderEndTag();
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.Write(reader.GetValue(1).ToString());
                        writer.RenderEndTag();
                        writer.RenderEndTag();

                        writer.AddAttribute(HtmlTextWriterAttribute.Valign, "bottom");
                        writer.AddAttribute(HtmlTextWriterAttribute.Height, "40px");
                        writer.RenderBeginTag(HtmlTextWriterTag.Tr);
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                        writer.AddAttribute(HtmlTextWriterAttribute.Href, "Users.aspx");
                        writer.RenderBeginTag(HtmlTextWriterTag.A);
                            writer.AddAttribute(HtmlTextWriterAttribute.Src, "../Modules/UserManager/img/back.jpg");
                            writer.RenderBeginTag(HtmlTextWriterTag.Img);
                        writer.RenderEndTag();

                        writer.AddAttribute(HtmlTextWriterAttribute.Align, "right");
                        writer.RenderBeginTag(HtmlTextWriterTag.Td);
                            writer.AddAttribute(HtmlTextWriterAttribute.Href, "Users.aspx?cmd=delete&id_user=" + reader.GetValue(0).ToString());
                            writer.RenderBeginTag(HtmlTextWriterTag.A);
                                writer.AddAttribute(HtmlTextWriterAttribute.Src, "../Modules/UserManager/img/del.jpg");
                                writer.RenderBeginTag(HtmlTextWriterTag.Img);
                                writer.RenderEndTag();
                            writer.RenderEndTag();
                        writer.RenderEndTag();


                        writer.RenderEndTag();
                    }
                command.Connection.Close();

            }

            writer.RenderEndTag();
            base.Render(writer);
        }
	}
